package com.web;


import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.entity.Employee;
import com.entity.Goal;
import com.entity.Project;
import com.service.EmployeeService;
import com.service.GoalService;

public class CreateTask extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String id=request.getParameter("id");
		
		GoalService goalService=new GoalService();
		Goal goal=goalService.getGoal(id);
		
		Project project=(Project)request.getSession().getAttribute("project");
		EmployeeService employeeService=new EmployeeService();
		Employee admin=employeeService.getAdmin(project.getId());
		List<Employee> workers=employeeService.getWorkers(project.getId());
		workers.add(admin);
		
		request.getSession().setAttribute("goalid", id);
		request.getSession().setAttribute("workersp",workers);
		request.getSession().setAttribute("goal", goal);
		request.getRequestDispatcher("WEB-INF/views/createTask.jsp").forward(request, response);
		
	}
	

}
